import { FilterType } from 'common/utils/eq-filter/types';
import { FilterOptionsWithId } from 'common/utils/eq-filter/types';

const FilterTypeNameMap: Record<FilterType, string> = {
  lowpass: 'Low Pass',
  highpass: 'High Pass',
  peaking: 'Peaking',
  lowshelf: 'Low Shelf',
  highshelf: 'High Shelf',
  allpass: 'All Pass',
};

const FilterTypeList: { label: string; value: FilterType }[] = [
  {
    label: FilterTypeNameMap['lowpass'],
    value: 'lowpass',
  },
  {
    label: FilterTypeNameMap['highpass'],
    value: 'highpass',
  },
  {
    label: FilterTypeNameMap['peaking'],
    value: 'peaking',
  },
  {
    label: FilterTypeNameMap['lowshelf'],
    value: 'lowshelf',
  },
  {
    label: FilterTypeNameMap['highshelf'],
    value: 'highshelf',
  },
];

const DefaultFilterRangeConfig = {
  frequency: {
    min: 20.0,
    max: 20000.0,
    step: 1.0,
    precision: 0,
  },
  gain: {
    min: -18.0,
    max: 12.0,
    step: 0.1,
    precision: 1,
  },
  q: {
    min: 0.1,
    max: 10.0,
    step: 0.1,
    precision: 1,
  },
};

const DefaultFilterValue: Omit<FilterOptionsWithId, 'id'> = {
  filterType: 'peaking',
  frequency: 1000.0,
  gain: 0.0,
  q: 1.0,
};

export const useGetFilterTypeName = () => {
  return FilterTypeNameMap;
};

export const useGetFilterType = () => {
  return {
    typeList: FilterTypeList,
    rangeConfig: DefaultFilterRangeConfig,
  };
};

export const useGetDefaultFilterValue = () => {
  return DefaultFilterValue;
};
